/*
*  Copyright 2019-2025 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.basic.rest;

import me.zhengjie.annotation.Log;
import me.zhengjie.modules.basic.domain.BasicAe03;
import me.zhengjie.modules.basic.service.BasicAe03Service;
import me.zhengjie.modules.basic.domain.dto.BasicAe03QueryCriteria;
import lombok.RequiredArgsConstructor;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.utils.PageResult;

/**
* @author ly
* @date 2025-04-30
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "当事人银行信息采集")
@RequestMapping("/api/basicAe03")
public class BasicAe03Controller {

    private final BasicAe03Service basicAe03Service;

    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('basicAe03:list')")
    public void exportBasicAe03(HttpServletResponse response, BasicAe03QueryCriteria criteria) throws IOException {
        basicAe03Service.download(basicAe03Service.queryAll(criteria), response);
    }

    @GetMapping
    @ApiOperation("查询当事人银行信息采集")
    @PreAuthorize("@el.check('basicAe03:list')")
    public ResponseEntity<PageResult<BasicAe03>> queryBasicAe03(BasicAe03QueryCriteria criteria){
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(basicAe03Service.queryAll(criteria,page),HttpStatus.OK);
    }

    @PostMapping("/getAe03")
    @ApiOperation("查询当事人银行信息采集")
    public ResponseEntity<PageResult<BasicAe03>> getAe03(@RequestBody BasicAe03QueryCriteria criteria){
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(basicAe03Service.queryAll(criteria,page),HttpStatus.OK);
    }


    @PostMapping
    @Log("新增当事人银行信息采集")
    @ApiOperation("新增当事人银行信息采集")
    @PreAuthorize("@el.check('basicAe03:add')")
    public ResponseEntity<Object> createBasicAe03(@Validated @RequestBody BasicAe03 resources) throws IOException {
        basicAe03Service.create(resources);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }

    @PutMapping
    @Log("修改当事人银行信息采集")
    @ApiOperation("修改当事人银行信息采集")
    @PreAuthorize("@el.check('basicAe03:edit')")
    public ResponseEntity<Object> updateBasicAe03(@Validated @RequestBody BasicAe03 resources) throws IOException {
        basicAe03Service.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @Log("删除当事人银行信息采集")
    @ApiOperation("删除当事人银行信息采集")
    @PreAuthorize("@el.check('basicAe03:del')")
    public ResponseEntity<Object> deleteBasicAe03(@ApiParam(value = "传ID数组[]") @RequestBody List<String> ids) throws IOException {
        basicAe03Service.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    @PostMapping("/getIa20i2")
    @ApiOperation("查询当事人银行信息采集")
    public ResponseEntity<List<BasicAe03>> getIa20i2(@RequestBody BasicAe03 param){
        return new ResponseEntity<List<BasicAe03>>( basicAe03Service.getIa20i2(param),HttpStatus.OK);
    }
}
